﻿using System;
using System.Collections.Generic;
using Sripirom.ATS.Core.Domain;
using Sripirom.ATS.Core.Messaging;

namespace Sripirom.ATS.Model.ServiceLog
{
    public class ServiceTransactionLog : EntityBase<Decimal>, IAggregateRoot
    {
        private IList<ServiceActivityLog> _serviceActivityLogs;
        public ServiceTransactionLog()
        {
            _serviceActivityLogs = new List<ServiceActivityLog>();
        }

        public ServiceStatus Status { get; set; }

        #region Before Log
        public Decimal SysServiceId { get; set; }

        public String ChanelRequest { get; set; }
        public String TransactionId { get; set; }
        public String ChannelCode { get; set; }
        #endregion 


        #region Body Log
        public String CompanyCode { get; set; }
        public String ServiceCode { get; set; }
        public String SubServiceCode { get; set; }
        public String TranferType { get; set; }
        public Decimal SysTransactionId { get; set; }
        #endregion

        #region After Log
        public String ChannelReply { get; set; }
       

        /// <summary>
        /// Mapping to ERROR_CODE and ERROR_DESC
        /// </summary>
        public MessageOutput Output { get; set; }
        #endregion

        public String Remark { get; set; }

        public String CreatedBy { get; set; }
        public DateTime CreatedDate { get; set; }
        public String UpdatedBy { get; set; }
        public DateTime UpdatedDate { get; set; }



        public IEnumerable<ServiceActivityLog> ServiceActivityLogs { get { return _serviceActivityLogs; } }

        public Boolean AddActivityLog(ServiceActivityLog activityLog) 
        {
            if (activityLog != null)
            {
                activityLog.ServiceTransactionLog = this;
                activityLog.CreatedBy = this.CreatedBy;
                activityLog.CreatedDate = DateTime.Now;

                _serviceActivityLogs.Add(activityLog);
                return true;
            }

            return false;
        }
   
    }


    public interface IServiceTransactionLogRepository : IRepository<ServiceTransactionLog, Decimal> { }
}
